package com.amado.course52Jvm;

/**
 * @author wangyulong
 * @version 1.5.0
 * @date 2020/5/5 23:54
 */
public class DeadLock {
    public static void main(String[] args) {
        Object lock1 = new Object();
        Object lock2 = new Object();
        new Thread(() -> {
            synchronized (lock1){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("lock 1");
                synchronized (lock2){

                }
            }
        }).start();
        new Thread(() -> {
            synchronized (lock2){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("lock 2");
                synchronized (lock1){

                }
            }
        }).start();
    }
}
